<div class="modal-dialog">
    <div class="modal-content">
        <form role="form" action="{:U('article/category_add')}" method="post" id="addForm">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">添加分类</h4>
            </div>
            <div class="modal-body">

                <div class="form-group">
                    <label for="name">分类名</label>
                    <input type="text" class="form-control" id="name" name="name" >
                </div>
                <div class="form-group">
                    <label for="pid">父分类</label>
                    <select name="pid" class="form-control">
                    	<option value="0">主分类</option>
                    	{$category_list}
                    </select>
                </div>
               <div class="form-group">
                    <label for="type">类型</label>
                    <select name="type" id="type" class="form-control">
                    	<option value="1" <eq name="type" value="1">selected</eq>>列表</option>
                    	<option value="2" <eq name="type" value="2">selected</eq>>单页</option>
                    </select>
                </div>

                <div class="form-group" >
                    <label for="type">静态URL</label>
                    <input type="text" class="form-control" name="url" id="url" />
                </div>

            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-danger">确认保存</button>
            </div>
        </form>
    </div>
    <script type="text/javascript">
    	$("#addForm").bootstrapValidator({              
    	                excluded: [':disabled'],
    	                feedbackIcons: {
    	                    valid: 'glyphicon glyphicon-ok',
    	                    invalid: 'glyphicon glyphicon-remove',
    	                    validating: 'glyphicon glyphicon-refresh'
    	                },
    	                submitHandler: function (validator, form, submitButton) {
    	                    validator.defaultSubmit();
    	                },
    	                fields: {
    	                    name: {
    	                        validators: {
    	                            notEmpty: {
    	                                message: '分类名不能为空'
    	                            }
    	                        }
    	                    }
    	                }
    	            });
        $("#type").change(function(){ 
        	var type = $(this).val();
        	$(".form-group[data-type]").hide().find("select").attr("disabled",true);
        	$(".form-group[data-type="+type+"]").show().find("select").attr("disabled",false);
        });
        
        $("#type").trigger("change");
    	
    </script>